<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/11/30
 * Time: 11:42
 */

namespace app\api\controller\v1;

use app\api\validate\IDMustBePostiveInt;

use app\api\model\Banner as BannerModel;
use app\api\Model\Product as ProductModel;
use app\lib\exception\BannerMissException;
use think\Controller;
use think\Db;
use think\Exception;

class Banner extends Controller
{
    /**
     * @api {get} /banner/all 获取所有轮播图
     * @apiName getBanner
     * @apiGroup Banner
     *
     * @apiSuccess {int} id   id
     * @apiSuccess {String} url 地址
     * @apiSuccess {String} pic 图片
     * @apiErrorExample {string} Error-Response:
     * 404 : 获取banner不存在
     */
    public function getBanner()
    {

        $banner = Db::name('banner')->field('id,title,pic,url')->select();
//        $banner = BannerModel::select();

        if (!$banner) {
            throw new BannerMissException();
        }
        return ($banner);
    }


}